vtd: fix memory allocation from NUMA node for VT-d.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Nov 2008 10:52:42 +0000 (10:52 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Nov 2008 10:52:42 +0000 (10:52 +0000)
Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
xen/drivers/passthrough/vtd/ia64/vtd.c
xen/drivers/passthrough/vtd/intremap.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/vtd/qinval.c
xen/drivers/passthrough/vtd/vtd.h
xen/drivers/passthrough/vtd/x86/vtd.c

index 42e94f7ef5f50e0d006cbfd122717a879d6d8d24..b0abcf69293bebfebb3b4f61d8f237e134742be3 100644 (file)
@@ -21,6 +21,7 @@
 #include <xen/sched.h>
 #include <xen/domain_page.h>
 #include <xen/iommu.h>
+#include <xen/numa.h>
 #include <asm/xensystem.h>
 #include <asm/sal.h>
 #include "../iommu.h"
@@ -44,12 +45,12 @@ void unmap_vtd_domain_page(void *va)
 }
 
 /* Allocate page table, return its machine address */
-u64 alloc_pgtable_maddr(void)
+u64 alloc_pgtable_maddr(struct domain *d)
 {
     struct page_info *pg;
     u64 *vaddr;
 
-    pg = alloc_domheap_page(NULL, 0);
+    pg = alloc_domheap_page(NULL, d ? MEMF_node(domain_to_node(d)) : 0);
     vaddr = map_domain_page(page_to_mfn(pg));
     if ( !vaddr )
         return 0;
index ced746611ea1e60a3faa9e0b1148f177df0dac85..c9a73f50c442c15a165fadc8bb4a8aebb784e54e 100644 (file)
@@ -502,7 +502,7 @@ int intremap_setup(struct iommu *iommu)
     ir_ctrl = iommu_ir_ctrl(iommu);
     if ( ir_ctrl->iremap_maddr == 0 )
     {
-        ir_ctrl->iremap_maddr = alloc_pgtable_maddr();
+        ir_ctrl->iremap_maddr = alloc_pgtable_maddr(NULL);
         if ( ir_ctrl->iremap_maddr == 0 )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
index e632dd285cfb6b97ebb5556c67995baef3370f8a..2a3310fadf24e6ce15a0ee58e53bce3fc7f7b1ae 100644 (file)
@@ -148,7 +148,7 @@ static u64 bus_to_context_maddr(struct iommu *iommu, u8 bus)
     root = &root_entries[bus];
     if ( !root_present(*root) )
     {
-        maddr = alloc_pgtable_maddr();
+        maddr = alloc_pgtable_maddr(NULL);
         if ( maddr == 0 )
         {
             unmap_vtd_domain_page(root_entries);
@@ -205,7 +205,7 @@ static u64 addr_to_dma_page_maddr(struct domain *domain, u64 addr, int alloc)
     addr &= (((u64)1) << addr_width) - 1;
     spin_lock_irqsave(&hd->mapping_lock, flags);
     if ( hd->pgd_maddr == 0 )
-        if ( !alloc || ((hd->pgd_maddr = alloc_pgtable_maddr()) == 0) )
+        if ( !alloc || ((hd->pgd_maddr = alloc_pgtable_maddr(domain)) == 0) )
             goto out;
 
     parent = (struct dma_pte *)map_vtd_domain_page(hd->pgd_maddr);
@@ -218,7 +218,7 @@ static u64 addr_to_dma_page_maddr(struct domain *domain, u64 addr, int alloc)
         {
             if ( !alloc )
                 break;
-            maddr = alloc_pgtable_maddr();
+            maddr = alloc_pgtable_maddr(domain);
             if ( !maddr )
                 break;
             dma_set_pte_addr(*pte, maddr);
@@ -605,7 +605,7 @@ static int iommu_set_root_entry(struct iommu *iommu)
     spin_lock_irqsave(&iommu->register_lock, flags);
 
     if ( iommu->root_maddr == 0 )
-        iommu->root_maddr = alloc_pgtable_maddr();
+        iommu->root_maddr = alloc_pgtable_maddr(NULL);
     if ( iommu->root_maddr == 0 )
     {
         spin_unlock_irqrestore(&iommu->register_lock, flags);
index d90242d70843cd9d63c8bc891488f7353b2d29ca..048089350dca66f867a0537cff0e2a4da7740b96 100644 (file)
@@ -426,7 +426,7 @@ int qinval_setup(struct iommu *iommu)
 
     if ( qi_ctrl->qinval_maddr == 0 )
     {
-        qi_ctrl->qinval_maddr = alloc_pgtable_maddr();
+        qi_ctrl->qinval_maddr = alloc_pgtable_maddr(NULL);
         if ( qi_ctrl->qinval_maddr == 0 )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
index 84cd2e5f8a4765cd93a5128deb261e0ff55d85af..ec02d129d8e6de87fc402a588e223825c7fd3e6b 100644 (file)
@@ -101,7 +101,7 @@ unsigned int get_cache_line_size(void);
 void cacheline_flush(char *);
 void flush_all_cache(void);
 void *map_to_nocache_virt(int nr_iommus, u64 maddr);
-u64 alloc_pgtable_maddr(void);
+u64 alloc_pgtable_maddr(struct domain *d);
 void free_pgtable_maddr(u64 maddr);
 void *map_vtd_domain_page(u64 maddr);
 void unmap_vtd_domain_page(void *va);
index 5a625351fd1ef3c35af0b61a77f47f33801f30ae..31dc5618813f3df5aa889d98448bf7830363f533 100644 (file)
@@ -22,6 +22,7 @@
 #include <xen/domain_page.h>
 #include <asm/paging.h>
 #include <xen/iommu.h>
+#include <xen/numa.h>
 #include "../iommu.h"
 #include "../dmar.h"
 #include "../vtd.h"
@@ -37,13 +38,13 @@ void unmap_vtd_domain_page(void *va)
 }
 
 /* Allocate page table, return its machine address */
-u64 alloc_pgtable_maddr(void)
+u64 alloc_pgtable_maddr(struct domain *d)
 {
     struct page_info *pg;
     u64 *vaddr;
     unsigned long mfn;
 
-    pg = alloc_domheap_page(NULL, 0);
+    pg = alloc_domheap_page(NULL, d ? MEMF_node(domain_to_node(d)) : 0);
     if ( !pg )
         return 0;
     mfn = page_to_mfn(pg);